//
//  ZYHistoricalRecordCell.m
//  BestLearning
//
//  Created by ちょうかんこん on 2017/11/1.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "ZYHistoricalRecordCell.h"
#import "ZYHistoricalRecordModel.h"

@implementation ZYHistoricalRecordCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
     
        [self setUpSuperView];
    }
    
    
    
    return self;
    
    
    
}




- (void)assignByZYHistoricalRecordModel:(ZYHistoricalSubRecordModel *)model{
    
    
    NSLog(@"ddddd");
    
    //self.nameLbel.text = [NSString stringWithFormat:@"%@回复%@",[[model valueForKey:@"poster"] valueForKey:@"petName"],[[[model valueForKey:@"reply"] valueForKey:@"replyer"] valueForKey:@"petName"]];
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@",[model valueForKey:@"createTime"]];
    self.teacherLabel.text = [NSString stringWithFormat:@"%@",[model valueForKey:@"content"]];
    
    
    NSString *uid = [AccountTool shareAccountTool].currentAccount.uid;
    
    NSString *uids = [NSString stringWithFormat:@"%@",[[model valueForKey:@"poster"] valueForKey:@"uid"]];
    
    
    
    if ([uid integerValue] == [uids integerValue]) {
        
        self.seeButton.hidden = YES;
        
    }else{
        
        self.seeButton.hidden = NO;
        
    }
    
    
    NSMutableAttributedString *hintString=[[NSMutableAttributedString alloc]initWithString: [NSString stringWithFormat:@"%@回复%@",[[model valueForKey:@"poster"] valueForKey:@"petName"],[[[model valueForKey:@"reply"] valueForKey:@"replyer"] valueForKey:@"petName"]]];
    
    
    //获取要调整颜色的文字位置,调整颜色
    NSRange range1=[[hintString string]rangeOfString:@"回复"];
    [hintString addAttribute:NSForegroundColorAttributeName value:ColorRGB(0,0,0) range:range1];
    [hintString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:range1];
    self.nameLbel.attributedText = hintString;
    
    
    if (self.teacherLabel) {
        
    }
    

}



    
- (void)setUpSuperView{
    
  
    
    self.nameLbel = [UILabel new];
    self.nameLbel.font = [UIFont systemFontOfSize:12];
    self.nameLbel.textColor = ColorRGB(51, 51, 51);
    self.nameLbel.numberOfLines = 0;
    [self.contentView addSubview:self.nameLbel];
    
    
    self.teacherLabel = [UILabel new];
    self.teacherLabel.font = [UIFont systemFontOfSize:14];
    self.teacherLabel.textColor = ColorRGB(51, 51, 51);
    [self.contentView addSubview:self.teacherLabel];
    
    self.timeLabel = [UILabel new];
    self.timeLabel.font = [UIFont systemFontOfSize:11];
     self.timeLabel.textColor = ColorRGB(102,102,102);
    [self.contentView addSubview:self.timeLabel];
    
    
    
    self.seeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.seeButton setImage:[UIImage imageNamed:@"icon_commend_defaulttt"] forState:(UIControlStateNormal)];
    self.seeButton.hidden = YES;
    [self.contentView addSubview:self.seeButton];
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    self.nameLbel.text = @"评价课程名称";
    [self.nameLbel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.offset(8);
        make.top.offset(10);
        make.right.equalTo(self).offset(-120);
        
        
        
    }];
    
    
    self.timeLabel.text = @"2015.10.11";
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-8);
        make.top.offset(10);
        
        
    }];
    
    
    self.teacherLabel.text = @"张宇老师张宇老师张宇老师张宇老师张宇老师张宇老师张宇老师张宇老师张宇老师";
    self.teacherLabel.numberOfLines = 0;
    [self.teacherLabel mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.equalTo(self.nameLbel);
        make.top.equalTo(self.nameLbel.mas_bottom).offset(15);
        make.right.equalTo(self).offset(-100);

    }];
//
//
//
//
//
    [self.seeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-8);
//        make.top.centerY.equalTo(self.teacherLabel);
        make.top.equalTo(self.nameLbel.mas_bottom).offset(15);
    }];

    

    
    
    
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(self.teacherLabel).offset(10);
    }];
//
    
    
    
    
}
    
    
    
    
    
@end
